package com.taotao.common.auth.satoken;

import cn.dev33.satoken.stp.StpUtil;
import com.taotao.common.auth.LoginService;
import com.taotao.common.auth.UserInfo;
import com.taotao.common.auth.UserInfoArgumentResolver;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * controller方法参数解析器
 * </p>
 *
 * @author ybwh
 * @since 2019年5月17日 下午2:30:09
 */
@Slf4j
@AllArgsConstructor
public class SatokenUserInfoArgumentResolver extends UserInfoArgumentResolver {

    private LoginService loginService;


    protected UserInfo getUserInfo(String token) {

        return loginService.getLoginUserInfo(token);

    }

    protected String getToken(HttpServletRequest request) {
        return StpUtil.getTokenValue();
    }

}
